package com.mercury.ec.framework.air.core.client.impl.sunstn.jaxb.adapter;

import cn.hutool.core.util.StrUtil;

import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 * jaxb 布尔类型转换适配器
 *
 * @author hesx
 */
public class Boolean2XmlAdapter extends XmlAdapter<String, Boolean> {

    @Override
    public Boolean unmarshal(String xml) throws Exception {
        if (StrUtil.isBlank(xml)) {
            return false;
        }
        return "1".equals(xml) ? true : false;
    }

    @Override
    public String marshal(Boolean result) throws Exception {
        return result ? "1" : "0";
    }
}
